package gui.newActions;

import java.awt.event.KeyEvent;
import java.util.ArrayList;

public class Util {

    public String posterization(String s){
        String temp = "";
        char[] stemp;
        stemp = s.toCharArray();
        for (int i=0; i < s.length(); i++){
            if (stemp[i] != KeyEvent.VK_SPACE){
                temp = temp + stemp[i];
            }
        }
        return temp;
    }

    public ArrayList<Integer> psort(ArrayList<Integer> first){
            Object temp;
            Object[] res = first.toArray();
            for (int i=0; i < res.length; i++){
                for (int j=0; j < (res.length-1); j++){
                    if(Integer.valueOf(res[j].toString()) > Integer.valueOf(res[j+1].toString())){
                        temp = res[j];
                        res[j] = res[j+1];
                        res[j+1] = temp;
                    }
                }
            }
            ArrayList<Integer> r = new ArrayList<Integer>();
            for (int i=0; i < res.length; i++){
                r.add(Integer.valueOf(res[i].toString()));
            }
            return r;
        }
    

}

